#include "stdafx.h"
#include "TextView.h"
#include "SkCanvas.h"

TextView::TextView(View* parent)
	: View(parent)
{
	font_ = std::shared_ptr<SkFont>(new SkFont(std::wstring(L"Arial"), 10));
}


TextView::~TextView()
{
}

void TextView::setFont(std::shared_ptr<SkFont> font)
{
	font_ = font;
}

std::shared_ptr<SkFont> TextView::getFont()
{
	return font_;
}

bool TextView::paint(SkCanvas* canvas)
{
	// paintBackground(canvas);

	paintFrontground(canvas);

	// paintBorder(canvas);

	return true;
}

bool TextView::paintBackground(SkCanvas* canvas)
{
	if (canvas)
	{
      canvas->FillRect(SkColor(255, 0, 0), 0, 0, Width(), Height());
	}
	return false;
}

bool TextView::paintFrontground(SkCanvas* canvas)
{
	if (canvas)
	{
		canvas->drawText(getText(), *font_, SkColor(255, 255, 255), 0, 0, Width(), Height());
		return true;
	}

	return false;
}
